package model

func AddHotMem(Mem string) error {
	re := NewRedisDBCntlr()
	defer re.Close()
	_, err := re.SADD(HotKey, Mem)
	return err
}

func GetHotKey() ([]string, error) {
	re := NewRedisDBCntlr()
	defer re.Close()
	return re.SMEMBERS(HotKey)
}

func DeleteHotkey(mem string) error {
	re := NewRedisDBCntlr()
	defer re.Close()
	_, err := re.SREM(HotKey, mem)
	return err
}

func ClearHotKey() error {
	re := NewRedisDBCntlr()
	defer re.Close()
	mems, err := re.SMEMBERS(HotKey)
	if err != nil {
		return err
	}
	for _, mem := range mems {
		_, err = re.SREM(HotKey, mem)
	}
	return err
}
